package com.soccerlover9527.jadis.datasturct;

import java.util.List;

/**
 * <p></p>
 *
 * @author soccerlover9527@gmail.com
 * @since 2023-08-07
 */
public interface JHash<K, V> extends Lengths {
    /**
     * put key value
     *
     * @param key   key
     * @param value value
     * @return 1 if set a new key, 0 if update value.
     */
    int put(K key, V value);

    /**
     * delete value by key
     *
     * @param key key
     * @return 0 if not exist key.
     */
    int delete(K key);

    /**
     * get value by key
     *
     * @param key key
     * @return null if not exist or return the value key mapped.
     */
    V get(K key);

    /**
     * check key exist in hash table.
     *
     * @param key key
     * @return true if existed.
     */
    boolean exist(K key);

    /**
     * get all key-values.
     * <p>example
     * input: set k1 v1 k2 v2</p>
     * <p>out: [k1,v1,k2,v2]</p>
     *
     * @return all key value data.[k1,v1,k2,v2]
     */
    List<?> getAll();

    /**
     * Add N to the specified value
     *
     * @return result value;
     */
    long increment(K key, long addend);

    /**
     * return all keys in hash table.
     *
     * @return list of all keys
     */
    List<K> keys();

    /**
     * return all values in hash table.
     *
     * @return list of all keys
     */
    List<V> values();
}
